<template>
  <!--  -->

  <div @click="showTest = !showTest">1</div>

  <div>
    <keep-alive>
      <test v-if="showTest"></test>
    </keep-alive>
  </div>

  <!-- <div @click="dddd">123</div> -->
</template>

<script></script>

<script setup>
import { onMounted } from "vue";
import request from "../../axios/request";
import test from "@/components/test/index.vue";
import useUtils from "@/utils";
const { $common, $router, $store, $global } = useUtils();

let showTest = $ref(true);
// onMounted(() => {
//   console.log(1235);
// });
let name = $ref("123");
onMounted(() => {
  let a = dddd();
  console.log(a);
  a.then((res) => {
    console.log(res);
  }).catch((err) => {
    console.log(err);
  });
  setTimeout(() => {
    a.abort();
  }, 2000);
});

function dddd() {
  let rejectFn = null;
  console.log(Promise);
  let promise1 = new Promise((resolve, reject) => {
    rejectFn = reject;
    setTimeout(() => {
      resolve(123);
    }, 5000);
  });
  console.log(rejectFn);
  promise1.abort = () => {
    rejectFn("中止promise");
  };

  return promise1;
}
</script>
<style lang="scss" scoped></style>
